package com.swust.exam.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.swust.exam.dao.StudentsMapper;
import com.swust.exam.pojo.Students;

@Service
public class StudentsService {
	@Autowired
	private StudentsMapper studentsmapper;
	
	public Students get(int id) {
		return studentsmapper.selectByPrimaryKey(id);
	}
	public Students login(String studentNumber, String studentPassword){
		return studentsmapper.login(studentNumber, studentPassword);
	}
	public int delete(int id) {
		return studentsmapper.deleteByPrimaryKey(id);
	}
	
	public int insert(Students info) {
		return studentsmapper.insert(info);
	}
	
	public int password_update(String studentPassword,String studentNumber){
		return studentsmapper.password_update(studentPassword, studentNumber);
	}
	
	public int update(Students info) {
		return studentsmapper.updateByPrimaryKey(info);
	}
	
	public List<Students> studentslist(){
		return studentsmapper.studentslist();
	}
	
	public List<Students> GetDetailStudentInfo() {
		return studentsmapper.GetDetailStudentInfo();
	}
	
	@Transactional
	public boolean BulkImport(List<Students>list) {
		for(Students st:list) {
			studentsmapper.insert(st);
		}
		return true;
	}
}
